Skip to content

fix: surface server error-channel messages as warnings - #354

Open
saravanan619 wants to merge 2 commits into
hyperliquid-dex:masterfrom
saravanan619:fix/websocket-error-channel-352
Open

saravanan619 wants to merge 2 commits into
hyperliquid-dex:masterfrom
saravanan619:fix/websocket-error-channel-352

Conversation

@saravanan619

Copy link
Copy Markdown

Fixes #352

Bug

When the server rejects a subscription it sends a message on the error channel. WebsocketManager.on_message calls ws_msg_to_identifier, which had no error branch, so it returned None and on_message logged "Websocket not handling empty message" at DEBUG and dropped it. With default logging the caller saw nothing.

Fix

  • ws_msg_to_identifier now maps channel == "error" to the "error" identifier.
  • on_message handles that identifier before the subscription lookup: it logs the server error at WARNING level (including the full message, so it is visible by default) and returns, without routing it to any subscription.

Tests

Added tests/websocket_manager_test.py (plain pytest, no network):

  • ws_msg_to_identifier returns "error" for error-channel messages.
  • An error-channel message produces a WARNING-level log containing the error text.
  • It is not routed to any subscription callback and does not print the unexpected-subscription line.

Tests were written red first (2 failed on the unmodified code) and pass with the fix. Full suite: 39 passed offline with the repo's default pytest options (--doctest-modules, --cov, --record-mode=once).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebsocketManager drops server error messages silently (logged only at debug)

1 participant